package com.eve.springcloud.service.impl;

import java.util.UUID;

import javax.annotation.Resource;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import com.eve.springcloud.service.IMessageService;

/**
 * 同RabbitMQ连接的接口实现，有些变化
 * @author HXL
 *
 */
@EnableBinding(Source.class)      // 定义消息的推送
public class IMessageServiceImpl implements IMessageService {

	@Resource
	private MessageChannel output;   // 消息发送管道
	
	@Override
	public String send() {
		String serial = UUID.randomUUID().toString();
		output.send(MessageBuilder.withPayload(serial).build());
		System.out.println("********serial:" + serial);
		return serial;
	}

}
